import time

import redis

shujuku = redis.StrictRedis(host='localhost', port=6379, db=0, decode_responses=True)  # 建立redis数据库实例
# #shujuku.set('shoupanbijiao', 1)
# shujuku.set('xianxinghuiguizhibiao', 4826.2)
# shujuku.set('shoupancelueshuju', '[0,0,0,0]')  # 放入收盘前数据

# while 1:
#     shujuku.set('dbzt', -1)  # 写入qian5fenzhong_dbzt值
#     time.sleep(1)

"""清空redis中的实时行情数据"""
data_key = shujuku.keys()  # 返回redis中的所有key
dingyueheyueliebiao = []
# 删除数据库指定前缀的所以数据
k = 0
for i, var2 in enumerate(data_key):
    lsbl_hy = var2.split('.')
    if lsbl_hy[0] == 'ruanjian88':  # 清空key前缀为HQ的记录
        shujuku.delete(var2)  # 删除redis中key为var2的记录
        print(var2)
